{% extends "layout.html" %}
{% block body %}
<body>
    <script type="text/javascript" charset="utf-8">
        $.util.namespace("odf");
        $(function () {
            var current_tab = $('#mainTabs').tabs('getSelected');
            //console.log(current_tab);
            var odf_tab = current_tab.find('.odfmb-tab');
            var odf_devid = odf_tab.data('devid');
            /*
            gj.dzs = gj_tab.data('dzs');
            console.log(gj.dzs.length);
            var jmpdzs = new Array();
            for (var i = 0; i < gj.dzs.length; i++) {
                //console.log(gj.dzs[i]['jmp.id0']);
                if (gj.dzs[i]['jmp.id0']) {
                    //console.log(gj.dzs[i]['jmp.id0']);
                    jmpdzs.push(gj.dzs[i]);

                }
            }
            console.log(jmpdzs.length);
            */

            
            
            odf.jmp_pt = odf_tab.find('span.jmp-pt');
    /*

            gj.jmp.each(function () {
                //console.log($(this).data('dz'));
                var jmp_port = $(this);
                var jmp_port_dz = $(this).data('dz');
                //var id0=$(this).data('id0');
                //console.log(c);
                //console.log(id0);
                for (var i = 0; i < jmpdzs.length; i++) {
                    if ((jmpdzs[i]['jmp.rdz'] == jmp_port_dz || jmpdzs[i]['jmp.cdz'] == jmp_port_dz) && jmpdzs[i]['dz.dz'] != jmp_port_dz) {
                        //console.log(jmpdzs[i]);
                        //console.log($(".pw[data-dz="+jmpdzs[i]['dz.dz']+"]").text());
                        pw_tip = gj_tab.find('.pw[data-dz="' + jmpdzs[i]['dz.dz'] + '"]').clone();
                        //console.log(tj);
                        jmp_port.after(pw_tip);
                    }

                }

            });
            
    */
            //跳接关系的端子点击高亮
            odf.jmp_pt.click(function () {
                odf.jmp_highlight = $(this).hasClass('highlight');
                odf.other_jmp_port_dz = $(this).next().data('dz');
                //console.log(gj.other_jmp_port_dz);
                odf.other_jump_port = odf_tab.find('.jmp-pt[data-dz="' + odf.other_jmp_port_dz + '"]');
                odf.jmp_pt.removeClass('highlight');

                if (!odf.jmp_highlight) {
                    $(this).addClass('highlight');
                    odf.other_jump_port.addClass('highlight');
                }
            });

            //跳接关系的文字显示
            odf.pw = odf_tab.find('span.pw');
            var pw_dict={};
            odf.pw.each(function(){
                pw_dict[$(this).data('dz')]=$(this).text();
            });
            odf.jmp_pw = odf_tab.find('span.jmp-pw');
            odf.jmp_pw.each(function(){
                $a = $('<a>').attr('href','#'+odf_devid+'-'+$(this).data('dz')).text(pw_dict[$(this).data('dz')]);
                $(this).append($a);
            });
            
            


            {#        gj.cds = gj_tab.find('.gjmb-tab').data('cds');#}
            {#        console.log(gj.cds.length);#}
            {#        for(var i=0;i<gj.cds.length;i++){#}
            {#            //console.log(gj.cds[i]['cd.dz']);#}
            {#            var cd_dz=gj.cds[i]['cd.dz'];#}
            {#            var cd_gl=gj.cds[i]['gld.mc']+'/'+gj.cds[i]['cd.qx'];#}
            {#            var $cd_gl="<br /><div style='background-color:skyblue'>"+cd_gl+"</div>";#}
            {#            gj_tab.find('.dz[data-dz="'+cd_dz+'"]').append($cd_gl);#}
            {#            #}
            {#        }#}


            //根据光缆成端div的高度调整tr的高度
            odf_tab.find('tr.tr_row').each(function () {
                //console.log($(this).data('dz'));
                //console.log($(this).find('th').text());
                //console.log('tr:'+$(this).height());
                //console.log('gl-cd:'+$(this).find('div.gl-cd').height());
                $(this).height($(this).height() + $(this).find('div.gl-cd').height()+ $(this).find('div.gl-tj').height()+1);
            });



        });
    </script>
    {#<div class="easyui-layout" data-options="fit:true">#}
        {#<div title="DataGrid" data-options="region: 'center', border: false, noheader: true">#}
            <div class="easyui-panel obdmb-tab" data-options="fit: true, border: false" style="padding:5px" data-devid="{{ devid }}">
                {#<div class="easyui-panel" data-options="collapsible:true, fit: false, border: false">#}
                    <h3>{{ obd_dev.bm }} ({{ obd_dev.mc }})</h3>
                    <table class="mb-table" border="1" cellspacing="0">
                        <thead>
                            <tr>
                            {% for mb in mbs %}
                                <th colspan="{{ mb.mk|length }}">{{ mb.mk_row }}</th>
                            {% endfor %}
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="tr_row">
                            {% for mb in mbs %}
                                {% for dz in mb.mk %}
                                <td style="width:2%" id="{{ devid }}-{{ dz['dz.dz'] }}" class="dz{% if dz['dz.zt']=='其他' %} otherport{% endif %}{% if dz['dz.zt']=='坏' %} badport{% endif %}" data-dz="{{ dz['dz.dz'] }}">
                                    <div class="dz-wrapper">
                                        <span class="pw" data-dz="{{ dz['dz.dz'] }}">{{ dz['dz.dz'] }}</span><br/>
                                        {% if dz['dz.bz'] %}
                                            {% if dz['dz.bz']|is_list %}
                                                {% for bz in dz['dz.bz'] %}
                                                    {{ bz or '' }}<br/>
                                                {% endfor %}
                                            {% else %}
                                                {{ dz['dz.bz'] }}
                                            {% endif %}
                                        {% endif %}
                                        <div class="dz-wrap">
                                        {% if dz['jmp.rdz'] %}
                                            <div class="gl-tj">
                                                <span class="jmp-pt" data-dz="{{ dz['dz.dz'] }}">◎</span>
                                                <span class="jmp-pw" data-dz="{% if dz['dz.dz']==dz['jmp.rdz'] %}{{ dz['jmp.cdz'] }}{% endif %}{% if dz['dz.dz']==dz['jmp.cdz'] %}{{ dz['jmp.rdz'] }}{% endif %}"></span>
                                            </div>
                                        {% endif %}
                                        </div>
                                    </div>
                                </td>
                                {% endfor %}
                            {% endfor %}
                            </tr>
                        </tbody>
                    </table>
                {#</div>#}
            </div>
        {#</div>#}
    {#</div>#}
</body>
{% endblock %}



